#ifndef _LT_SINGLETON_H_
#define _LT_SINGLETON_H_

//#include <assert.h>

namespace Lotus
{
	namespace Utilities
	{
		template <class T> 
		class Singleton
		{
		protected:
			Singleton()
			{
				//assert(instance==0);
				instance=static_cast<T*>(this);
			}

			virtual ~Singleton(){}

			static T* getInstancePtr()
			{
				//assert(instance);
				return instance;
			}

			static T& getInstance()
			{
				//assert(instance);
				return *instance;
			}

		private:
			static T* instance;
		};
	}
}

#define LT_DECLARE_SINGLETON(T)\
	static T * getInstancePtr();\
	static T & getInstance();

#define LT_IMPLEMENT_SINGLETON(T)\
	T * ::Lotus::Utilities::Singleton< T >::instance=NULL;\
	T * T ::getInstancePtr(){return Singleton< T >::getInstancePtr();}\
	T & T ::getInstance(){return Singleton< T >::getInstance();}

#endif